Stream API topic
This API can operate on an unbuffered (i.e., 'lazy') stream of data. It simply buffers it into a kXXH3StreamBufferSize-byte buffer and computes some rounds once the buffer reaches capacity or the final digest call is made.
This means memory usage should hover around the buffer size - even for huge (e.g., several gigabytes) payloads!
For small payload sizes (i.e., less than kXXH3SmallDataSize); this method likely introduces unnecessary overhead in terms of operations and the API so you would be better off using the buffer API (xxh3) unless you specifically need the streaming API.
Typical use cases for the streaming API are hashing large files, or working with data of an unknown size.
Constants
- kSecretSizeMin → const int Buffer API Stream API
- The absolute minimum size for a custom secret as defined in XXH3. See https://github.com/Cyan4973/xxHash/blob/b1a61dff654af43552b5ee05c737b6fd2a0ee14b/xxhash.h#L931
- kXXH3SmallDataSize → const int Buffer API Stream API
- The maximum size, in bytes, of a 'short' key. This is known internally to XXH3 as the 'mid-size max'.
- kXXH3StreamBufferSize → const int Stream API
- The optimal update size for incremental hashing. This size is used in the internal XXH3State when calling XXH3State.update.
Functions
-
xxh3Stream(
{Uint8List? secret, int? seed}) → XXH3State Stream API - Create an XXH3 stream (XXH3State). This state can be updated (XXH3State.update) with data as many times as desired, then digested with XXH3State.digest to compute the final hash.